import { assign } from 'muka'
import { combineReducers } from 'redux'
// import { IHomeState } from '../state'

function user(state: any = {}, action: any = {}) {
    switch (action.type) {
        case 'SET_USER_INFO': {
            const data = { ...state }
            data.userInfo = action.data
            return data
        }

        case 'SET_USER_ORDER_NUMBER': {
            const data: any = assign({}, state)
            data.userInfo.order_number = action.data
            return data
        }

        case 'SET_USER_COLLECTION': {
            const data = { ...state }
            data.collData = action.data
            return data
        }
        case 'SET_USER_FOLLOW': {
            const data = { ...state }
            data.followData = action.data
            return data
        }
        case 'SET_USER_FOOTPRINT': {
            const data = { ...state }
            data.footprintData = action.data
            return data
        }
        case 'SET_USER_MESSAGE': {
            const data = { ...state }
            data.msgData = action.data
            return data
        }
        case 'SET_USER_ORDERDATA': {
            const data: any = assign({}, state)
            data.orderData[action.status] = action.data
            return data
        }
        case 'SET_USER_ORDER_INDEX': {
            const data: any = { ...state }
            data.orderIndex = action.data
            return data
        }
        case 'SET_USER_ORDERDETAIL': {
            const data: any = { ...state }
            data.orderDetail = action.data
            return data
        }
        case 'SET_RETURNPOLICY_DATA': {
            const data: any = { ...state }
            data.returnpolicyData = action.data
            return data
        }
        case 'SET_USER_RETURN_DETAIL': {
            const data: any = { ...state }
            data.returnDetail = action.data
            return data
        }
        case 'SET_USER_RETURN_LISIT': {
            const data: any = assign({}, state)
            data.returnList[action.status] = action.data
            return data
        }
        case 'SET_USER_EXPRESS_DATA': {
            const data: any = { ...state }
            data.selectExpressData = action.data
            return data
        }
        case 'SET_USER_RETURN_BALANCE': {
            const data: any = { ...state }
            data.userBalance = action.data
            return data
        }
        case 'SET_USER_RETURN_BILL': {
            const data: any = { ...state }
            data.userBill = action.data
            return data
        }
        case 'SET_USER_BEAN_BILL': {
            const data: any = { ...state }
            data.userBeanBill = action.data
            return data
        }
        case 'SET_NEW_ADDRESS': {
            const data: any = assign({}, state)
            data.newAddress = action.data
            return data
        }
        case 'SET_DETAIL_Beans': {
            const data: any = assign({}, state)
            data.userBeans = action.data
            return data
        }
        case 'SET_MYUTILS_CREDITOR': {
            const data: any = assign({}, state)
            data.userCreditor = action.data
            return data
        }
        case 'SET_MYUTILS_DEBT': {
            const data: any = assign({}, state)
            data.userDebt = action.data
            return data
        }
        case 'SET_MYUTILS_DEPT_ZWMANAGEID': {
            const data: any = assign({}, state)
            data.userDebtManagerID = action.data
            return data
        }
        case 'SET_MYUTILS_BEANS': {
            const data: any = assign({}, state)
            data.userBeans = action.data
            return data
        } 
        case 'SET_MYUTILS_DEBTREVEIVEHD': {
            const data: any = assign({}, state)
            data.userDebtReceiveHD = action.data
            return data
        } 
        case 'SET_MYUTILS_DEBTREVEIVEHDSOLD': {
            const data: any = assign({}, state)
            data.userDebtReceiveHDSold = action.data
            return data
        } 
        case 'SET_MYUTILS_DEBTREVEIVEHDALL': {
            const data: any = assign({}, state)
            data.userDebtReceiveHDAll = action.data
            return data
        }
        case 'SET_MYUTILS_HYPOREVEIVEHD': {
            const data: any = assign({}, state)
            data.userHypoReceiveHD = action.data
            return data
        } 
        case 'SET_MYUTILS_HYPOREVEIVEHDSOLD': {
            const data: any = assign({}, state)
            data.userHypoReceiveHDSold = action.data
            return data
        } 
        case 'SET_MYUTILS_HYPOREVEIVEHDALL': {
            const data: any = assign({}, state)
            data.userHypoReceiveHDAll = action.data
            return data
        }
        case 'SET_MYUTILS_BEANSSOLDLISTALL': {
            const data: any = assign({}, state)
            data.userBeanSoldListAll = action.data
            return data
        } 
        case 'SET_MYUTILS_BEANSSOLDLISTSOLD': {
            const data: any = assign({}, state)
            data.userBeanSoldListSold = action.data
            return data
        } 
        case 'SET_MYUTILS_BEANSSOLDLISTUNSOLD': {
            const data: any = assign({}, state)
            data.userBeanSoldListUnsold = action.data
            return data
        }
        case 'SET_USER_DEFAULT_ADDRESS': {
            const data: any = assign({}, state)
            data.defaultAddress = action.data
            return data
        }
        case 'SET_USER_EXPRESSINFO': {
            const data: any = assign({}, state)
            data.expressInfo = action.data
            return data
        }
        case 'SET_MYUTILS_SIGNATURE': {
            const data: any = assign({}, state)
            data.suerSignature = action.data
            return data 
        }
        case 'SET_MYUTILS_SIGNATURESTUTS': {
            const data: any = assign({}, state)
            data.suerSignatureStatus = action.data
            return data 
        }
        case 'SET_WX_INFO': {
            const data: any = assign({}, state)
            data.wxInfo = action.data
            return data 
        }
        case 'SET_USER_BALANCE_BANK': {
            const data: any = assign({}, state)
            data.userBalanceSelectBank = action.data
            return data 
        }
        case 'SET_USER_RETURN_BILL_COUNT': {
            const data: any = assign({}, state)
            data.userBlanceBillCount = action.data
            return data 
        }
        case 'SET_USER_BEAN_BILL_COUNT': {
            const data: any = assign({}, state)
            data.userBeanBillCount = action.data
            return data 
        }
        case 'SET_MYUTILS_HYPOEXCHANGELIST': {
            const data: any = assign({}, state)
            data.userHypoExchangeList = action.data
            return data 
        }
        case 'SET_MYUTILS_DEBTEXCHANGELIST': {
            const data: any = assign({}, state)
            data.userDebtExchangeList = action.data
            return data 
        }
        case 'SET_MYUTILS_DEBTEXCHANGELISTRECORD': {
            const data: any = assign({}, state)
            data.userDebtExchangeListRecord = action.data
            return data 
        }
        
        default:
            return state
    }
}

function home(state: any = {}, action: any = {}) {
    switch (action.type) {
        case 'CHANGE_NAME':
            return {
                list: '1111'
            }
        default:
            return {
                list: 'ssssss'
            }
    }
}

function cate(state: any = {}, action: any = {}) {
    switch (action.type) {
        case 'SET_CATEGORY':
            const data: any = assign({}, state)
            data.lists = action.data
            return data
        default:
            return state
    }
}

function beans(state: any = {}, action: any = {}) {
    switch (action.type) {
        case 'SET_BEANS_ORDER':
            const data: any = assign({}, state)
            data.order = action.data
            return data
        default:
            return state
    }
}

function detail(state: any = {}, action: any = {}) {
    switch (action.type) {
        case 'SET_DETAIL_LIST': {
            const data: any = assign({}, state)
            data.list[action.status] = action.data
            return data
        }
        case 'SET_DETAIL_DATA': {
            const data: any = { ...state }
            data.info = action.data
            return data
        }
        case 'SET_DETAIL_ADDRESS': {
            const data: any = { ...state }
            data.addressData = action.data
            return data
        }
        case 'SET_DETAIL_SPEC': {
            const data: any = { ...state }
            data.spec = action.data
            return data
        }
        case 'SET_DETAIL_CART': {
            const data: any = { ...state }
            data.cartData = action.data
            return data
        }
        case 'SET_SHOP_BUS': {
            const data: any = { ...state }
            data.shopBusInfo = action.data
            return data
        }
        case 'SET_SHOP_BUS_RX': {
            const data: any = { ...state }
            data.shopBusRX = action.data
            return data
        }
        case 'SET_SHOP_BUSALL': {
            const data: any = { ...state }
            data.shopBusAll = action.data
            return data
        }
        case 'SET_SHOP_BUSPROMOTION': {
            const data: any = { ...state }
            data.shopBusPromotion = action.data
            return data
        }
        case 'SET_SHOP_BUSNEW': {
            const data: any = { ...state }
            data.shopBusNew = action.data
            return data
        }
        case 'SET_SHOP_BUSCATEGORY': {
            const data: any = { ...state }
            data.shopBusCategory = action.data
            return data
        }
        case 'SET_MYUTILS_HYPOAUTOSELECT': {
            const data: any = assign({}, state)
            data.isAutoSelect = action.data
            return data 
        }
        case 'SET_MYUTILS_HYPODETAIL': {
            const data: any = assign({}, state)
            data.userHypoDetail = action.data
            return data 
        }
        case 'SET_DETAIL_CATEGORYTHIRDLIST': {
            const data: any = assign({}, state)
            data.categoryThirdList = action.data
            return data 
        }
        case 'SET_DETAIL_CATEGORYTHIRDINDEX': {
            const data: any = assign({}, state)
            data.categoryThirdIndex = action.data
            return data 
        }
        case 'SET_DETAIL_CATEGORYTHIRDLISTINDEX': {
            const data: any = assign({}, state)
            data.categorySecondIndex = action.data
            return data 
        }
        default:
            return state
    }
}
function hist(state: any = {}, action: any = {}) {
    switch (action.type) {
        case 'SET_HIST_ROUTER':
            const data: any = assign({}, state)
            data.path = action.data
            return data
        default:
            return state
    }
}
export default combineReducers({
    home,
    user,
    cate,
    detail,
    beans,
    hist
})